package cn.gok.oop;

/**
 * @ClassName 继承
 * @Description TODO
 * @Author HP
 * @Date 14:05 2022/7/5
 * @Version 1.0
 **/
class Animal{
    private String name;
    private String sex;
    private int age;

    public Animal() {
    }

    public Animal(String name, String sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public void call(){
        System.out.println(this.name);
    }
}

class Dog extends Animal{
    private String owner;

    public Dog(String owner) {
        this.owner = owner;
    }

    public Dog(String name, String sex, int age, String owner) {
        super(name, sex, age);
        this.owner = owner;
    }

    public Dog() {
        super("狗", "男", 1);
    }

    @Override
    public void call() {
        super.call();
    }
}
class Parent{
    private int x;
    private int y;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Parent(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Parent() {
    }

    @Override
    public String toString() {
        return "Parent{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}
class Child extends Parent {
    private int z;

    public Child(int x, int y, int z) {
        super(x, y);
        this.z = z;
    }

    public Child(int z) {
        this.z = z;
    }

    public int getZ() {
        return z;
    }

    public void setZ(int z) {
        this.z = z;
    }
    public void getSum(){
        System.out.println(this.getX()+this.getY()+this.getZ());
    }
}
public class 继承 {
    public static void main(String[] args) {
//        Dog dog = new Dog();
//        dog.call();
        Child child = new Child(1,2,3);
        child.getSum();
    }

}
